/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ez2find.util;

import java.util.Map;
import javax.faces.context.FacesContext;

/**
 *
 * @author Administrador
 */
public class ApplicationContext {

    /** Creates a new instance of ApplicationContext */
    public ApplicationContext() {
    }
    
    
    public static void setAttribute(String name, Object object){
        Map att=getContext();
        att.put(name, object);
    }
    
    
    /**
     * return null if thers's no object under the name
     * param name the object's name in the application context
     * return the object under the name or null if there's no such name
     */
     
    public static Object getAttribute(String name){
        Map map=getContext();
        if (!map.containsKey(name)){
            return null;
        }
        
        return map.get(name);
     
    }
    
    
    
    private static Map getContext(){
        return FacesContext.getCurrentInstance().getExternalContext().getApplicationMap();
    }
}